package xin.clips.system.service.impl;

import xin.clips.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xin.clips.common.core.text.Convert;
import xin.clips.system.domain.gy.GyDeviceEarlywarnRecord;
import xin.clips.system.mapper.gy.GyDeviceEarlywarnRecordMapper;
import xin.clips.system.service.gy.IGyDeviceEarlywarnRecordService;
import java.util.List;

/**
 * 设备预警记录Service业务层处理
 *
 * @author clips
 * @date 2023-03-21
 */
@Service
public class GyDeviceEarlywarnRecordServiceImpl implements IGyDeviceEarlywarnRecordService
{
    @Autowired
    private GyDeviceEarlywarnRecordMapper gyDeviceEarlywarnRecordMapper;

    /**
     * 查询设备预警记录
     *
     * @param earlyWarnId 设备预警记录主键
     * @return 设备预警记录
     */
    @Override
    public GyDeviceEarlywarnRecord selectGyDeviceEarlywarnRecordByEarlyWarnId(Long earlyWarnId)
    {
        return gyDeviceEarlywarnRecordMapper.selectGyDeviceEarlywarnRecordByEarlyWarnId(earlyWarnId);
    }

    /**
     * 查询设备预警记录列表
     *
     * @param gyDeviceEarlywarnRecord 设备预警记录
     * @return 设备预警记录
     */
    @Override
    public List<GyDeviceEarlywarnRecord> selectGyDeviceEarlywarnRecordList(GyDeviceEarlywarnRecord gyDeviceEarlywarnRecord)
    {
        return gyDeviceEarlywarnRecordMapper.selectGyDeviceEarlywarnRecordList(gyDeviceEarlywarnRecord);
    }

    /**
     * 新增设备预警记录
     *
     * @param gyDeviceEarlywarnRecord 设备预警记录
     * @return 结果
     */
    @Override
    public int insertGyDeviceEarlywarnRecord(GyDeviceEarlywarnRecord gyDeviceEarlywarnRecord)
    {
        gyDeviceEarlywarnRecord.setCreateTime(DateUtils.getNowDate());
        return gyDeviceEarlywarnRecordMapper.insertGyDeviceEarlywarnRecord(gyDeviceEarlywarnRecord);
    }

    /**
     * 修改设备预警记录
     *
     * @param gyDeviceEarlywarnRecord 设备预警记录
     * @return 结果
     */
    @Override
    public int updateGyDeviceEarlywarnRecord(GyDeviceEarlywarnRecord gyDeviceEarlywarnRecord)
    {
        gyDeviceEarlywarnRecord.setUpdateTime(DateUtils.getNowDate());
        return gyDeviceEarlywarnRecordMapper.updateGyDeviceEarlywarnRecord(gyDeviceEarlywarnRecord);
    }

    /**
     * 批量删除设备预警记录
     *
     * @param earlyWarnIds 需要删除的设备预警记录主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceEarlywarnRecordByEarlyWarnIds(String earlyWarnIds)
    {
        return gyDeviceEarlywarnRecordMapper.deleteGyDeviceEarlywarnRecordByEarlyWarnIds(Convert.toStrArray(earlyWarnIds));
    }

    /**
     * 删除设备预警记录信息
     *
     * @param earlyWarnId 设备预警记录主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceEarlywarnRecordByEarlyWarnId(Long earlyWarnId)
    {
        return gyDeviceEarlywarnRecordMapper.deleteGyDeviceEarlywarnRecordByEarlyWarnId(earlyWarnId);
    }

    /**
     * 返回预警的总数
     *
     * @return 设备告警记录集合
     */
    public int selectTotal(){
        return gyDeviceEarlywarnRecordMapper.selectTotal();
    }


    /**
     * 查询设备预警记录列表
     *
     * @param gyDeviceEarlywarnRecord 设备预警记录
     * @return 设备预警记录集合
     */
    public List<GyDeviceEarlywarnRecord> selectGyDeviceEarlywarnRecordListLimit(GyDeviceEarlywarnRecord gyDeviceEarlywarnRecord){
        return gyDeviceEarlywarnRecordMapper.selectGyDeviceEarlywarnRecordListLimit(gyDeviceEarlywarnRecord);
    }

    /**
     * 查询设备预警每日数据
     *
     * @param gyDeviceEarlywarnRecord 设备预警记录
     * @return 设备预警记录集合
     */
    public List<GyDeviceEarlywarnRecord> selectEarlyWarnDayAnalyByTime(GyDeviceEarlywarnRecord gyDeviceEarlywarnRecord){
        return gyDeviceEarlywarnRecordMapper.selectEarlyWarnDayAnalyByTime(gyDeviceEarlywarnRecord);
    }
}
